Skip to content

Conversation

@cmaloney
Copy link
Contributor

@cmaloney cmaloney commented May 21, 2025

Also improves non-blocking support (gh-57531) and unbuffered support (gh-61606)

While behavior doesn't (generally) change it adds a lot of new warnings so I feel this is more of a feature (support non-blocking and unbuffered!) than a bugfix.

TODO before non-Draft

  • Review what type each warning should be
  • Validate if should warn on None (if so, fix CPython test cases)
  • Implement a blocking I/O write test like the one for BufferedIO (test_nonblock_pipe_write_bigbuf)
  • Add a partial write test

Also improves non-blocking support (pythongh-57531) and unbuffered support (pythongh-61606)
@cmaloney cmaloney force-pushed the wip/blocking_partial_io branch from 696abe7 to 4173474 Compare May 21, 2025 20:56
@cmaloney
Copy link
Contributor Author

I'm at the PyConUS sprints, would appreciate a high-level review / if the approach I took here looks like what you expect. In particular I tried to keep behavior around all the unexpected potential return values from buffer.write but also add DeprecationWarning/RuntimeWarning for many. I'm planning to work on expanding tests for this tomorrow (clone of BufferedIO blocking test, tests for underlying writers that return all the bad values, partial write tests, etc).

cc: @vstinner, @serhiy-storchaka (commented on the underlying issue, but also was quite a while ago. If there's better experts or someone more appropriate let me know)

@cmaloney
Copy link
Contributor Author

As I'm working on BufferedIO seeing a lot of cases where the buffering logic I'm testing moving towards there is very similar to what TextIOWrapper is doing internally, and hope I may be able to reduce a bit between the two (and allow utf-8 containing/encoded unicode objects to be buffered without a memcpy to make a temporary bytes object). I think that'll be a lot simpler than this, although may revisit depending on timelines.

@cmaloney cmaloney closed this Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant